﻿/***************************
* 1.游
* 2.景区列表
* 3.景区详情
* 4.景点详情
* 5.门票预订
****************************/

/* 变量 */
var scenic = "booking/scenic.html";
var ticket = "booking/ticket.html";
var ticketDetail = "booking/ticketDetail.html";
var ticketDetail02 = "booking/ticketDetail02.html";

/***********    地图使用公共方法    **********/
//地图跳转-类似周边，跳转景区，要iframe能使用
function MapClickJump(url, param) {
    mainView.router.loadPage({ url: url, reload: false });
}
//调用语音接口，返回给子界面--地图使用
var voice = {
    localId: '',
    serverId: ''
};
function ReturnStartVoice() {
    wx.startRecord({
        cancel: function () {
            alert('用户拒绝授权录音');
        }
    });
};
function ReturnEndVoid(callback) {
    wx.stopRecord({
        success: function (res) {
            voice.localId = res.localId;
            wx.translateVoice({
                localId: voice.localId, // 需要识别的音频的本地Id，由录音相关接口获得
                isShowProgressTips: 1, // 默认为1，显示进度提示
                success: function (res) {
                    if (res.translateResult != 'undefined' && res.translateResult != '') {
                        yy = res.translateResult.replace(/['",.!?，。？！]/ig, ""); // 语音识别的结果
                        callback(yy);
                    }
                }
            });
        },
        fail: function (res) {
            alert(JSON.stringify(res));
        }
    });
};
//语音按钮事件
/* 初始化语音config */
var gn = ['startRecord', 'stopRecord', 'translateVoice', 'openLocation', 'getLocation'];
wx_config(gn, function () {
    //callback 所有JSSDK事件
}, function () {
    //errorcallback  config注册失败事件
});
/***********    地图使用公共方法----结束    **********/

/* 游 */
var contactsCallback_scenic = myApp.onPageInit('scenic', function (page) {

    // 过滤 全部美食显示


    $$(".navbar-inner .right img").hide();


    var pickerRegion; //所在区域
    var pickerScenicType; //景区类型
    var pickerScenicStar; //景区等级
    var pickerScenicPriceRange; //价格范围

    pickerRegion = myApp.picker({
        input: '#sel_region_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.district(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.district(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicType = myApp.picker({
        input: '#sel_scenic_type_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicType(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicType(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicStar = myApp.picker({
        input: '#sel_scenic_star_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicStar(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicStar(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicPriceRange = myApp.picker({
        input: '#sel_scenic_price_range_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicPriceRange(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicPriceRange(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    //点击第一次页面执行
    var flag_tabs_tab1 = true;
    var flag_tabs_tab2 = true;
    //删除滚动后重新添加滚动
    var flag_InfiniteScroll = true;
    //是否需要滚动加载
    var flag_needScroll = true;
    //滚动事件只执行一次
    var flag_execute = false;

    var index_tab1 = 1;
    var index_tab2 = 1;
    var index_tab3 = 1;
    var index_tab4 = 1;
    var index_tab5 = 1;
    var current_tabindex = 0;
    var size = 10;
    // 加载flag
    var loading = false;
    /* 分类 */

    current_tabindex = 1;
    $$("#sub_buttons_row a").eq(0).removeClass("active");
    $$("#sub_buttons_row a").eq(0).hide();
    $$("#sub_buttons_row a").eq(1).addClass("active");
    $$("#scenic_tab2 #sub_tab1").removeClass("active");
    $$("#scenic_tab2 #sub_tab2").addClass("active");
    // 默认加载全部
    // LoadTicketAll(index_tab2, size);
    LoadTicket();



    //全部
    $$("#buttons-tabs a").click(function () {
        $$('.infinite-scroll').scrollTop(0);
        if ($$(this).index() == 0) {
            $$(".searchbar").hide();
            $$(".sub_buttons_row").hide();
            $$(".page-content").css("padding-top", "44px");
        }
        else {
            $$(".searchbar").css("display", "");
            $$(".sub_buttons_row").css("display", "");
            $$(".page-content").css("padding-top", "");
        }

        if ($$(this).index() == 1 && flag_tabs_tab2) {
            LoadTicketAll(index_tab1, size);
            flag_tabs_tab2 = false;
        }

        // if ($$(this).index() == 0 && flag_tabs_tab1) {
        //     LoadTicket();
        //     flag_tabs_tab1 = false;
        // }
    });

    // 加载非游不可
    function LoadTicket() {
        // 过滤
        $$(".navbar-inner .right img").hide();
        // JSON
        var _conditionParams = JSON.stringify({
            type: 7,
            Identifier: ISS_Constants.Identifier.you
        });

        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.CMS,
            crossDomain: true,
            data: { "content": _conditionParams },
            method: "GET",
            success: function (data, status) {
                data = JSON.parse(data);
                if (data && data.status == "0" && data.results.length > 0) {
                    for (var i = 0; i < data.results.length; i++) {
                        // 格式化数据
                        for (var j = 0; j < data.results[i].value.length; j++) {
                            if (data.results[i].value[j].F_SmallImage == undefined || data.results[i].value[j].F_SmallImage == null || data.results[i].value[j].F_SmallImage == "") {
                                data.results[i].value[j].F_SmallImage = NoPicture();
                            };
                            if (data.results[i].value[j].mobileOutUrl && data.results[i].value[j].mobileOutUrl != null &&
                                data.results[i].value[j].mobileOutUrl != "") {
                                data.results[i].value[j].mobileOutUrl = encodeURIComponent(data.results[i].value[j].mobileOutUrl);
                            };
                            if (data.results[i].value[j].Describes == undefined || data.results[i].value[j].Describes == null || data.results[i].value[j].Describes == "") {
                                data.results[i].value[j].Describes = data.results[i].value[j].WEB_BASE_ATTRACTIONS_Summary;
                            };
                        }
                        if (data.results[i].name == "tuijianjingqu") {
                            var searchTemplate = $$('#template-scenic-tab1').html();
                            if (searchTemplate) {
                                var compiledTemplate = Template7.compile(searchTemplate);
                                var html = compiledTemplate(data.results[i]);
                                $$("#scenic_tab1 .content-block").html(html);
                                flag_InfiniteScroll = flag_needScroll = true;
                            }
                        }
                    };
                } else {
                    $$("#scenic_tab1 .content-block").html("");
                }
            },
            error: function (xhr, status) { }
        });
    }

    //加载数据
    function LoadTicketAll(pageindex, pagesize) {
        // 检索条件
        var v_search = [];
        var v_order = [];

        var v_longitude = "";
        var v_latitude = "";

        // 站点
        if (_cityCode != "") {
            var opt = {
                SearchField: "CityCode",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: _cityCode
                    }
                ]
            };
            v_search.push(opt);
        }

        // 区域
        if (pickerRegion && pickerRegion.value && pickerRegion.value.length > 0) {
            v_search.push(
                {
                    SearchField: "District",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerRegion.value[0]
                        }
                    ]
                }
            );
        }

        // 餐厅类型
        if (pickerScenicType && pickerScenicType.value && pickerScenicType.value.length > 0) {
            v_search.push(
                {
                    SearchField: "AttrType",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicType.value[0]
                        }
                    ]
                }
            );
        }

        // 景区星级
        if (pickerScenicStar && pickerScenicStar.value && pickerScenicStar.value.length > 0) {
            v_search.push(
                {
                    SearchField: "AttrRating",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicStar.value[0]
                        }
                    ]
                }
            );
        }

        // 价格范围
        if (pickerScenicPriceRange && pickerScenicPriceRange.value) {
            v_search.push(
                {
                    SearchField: "PriceRange",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicPriceRange.value[0]
                        }
                    ]
                }
            );
        }

        // 搜索条件
        if (mySearchbar && mySearchbar.query) {
            var opt = {
                SearchName: "名称",
                SearchField: "Keyword",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: mySearchbar.query
                    }
                ]
            };
            v_search.push(opt);
        }

        // 排序
        if (current_tabindex == 0) {
            v_order = [
                {
                    OrderName: "最新",
                    OrderField: "ModifyTime", //最新
                    OrderType: "desc"
                }
            ];
        }
        if (current_tabindex == 1) {
            v_order = [
                {
                    OrderField: "Sort", //综合
                    OrderType: "desc"
                }
            ];
        }
        else if (current_tabindex == 2) {
            v_order = [
                {
                    OrderField: "scoreOrder", //评分
                    OrderType: "asc"
                }
            ];
        }
        else if (current_tabindex == 3) {
            v_order = [
                {
                    OrderField: "priceOrder", //价格
                    OrderType: "asc"
                }
            ];
        }
        else if (current_tabindex == 4) {
            v_order = [
                {
                    OrderField: "distanceOrder", //距离
                    OrderType: "asc"
                }
            ];
        }

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        var _content = JSON.stringify({
            type: 0,
            conditionParams: {
                Page: {
                    PageSize: pagesize,
                    PageIndex: pageindex
                },
                Search: v_search,
                Order: v_order
            },
            lng: v_longitude,
            lat: v_latitude,
        })

        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR,
            data: { "content": _content },
            crossDomain: true,
            method: "POST",
            success: function (data, status) {
                myApp.hidePreloader();
                data = JSON.parse(data);
                loading = false;
                if (current_tabindex == 0 && index_tab1 == 1) {
                    $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 1 && index_tab2 == 1) {
                    $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 2 && index_tab3 == 1) {
                    $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 3 && index_tab4 == 1) {
                    $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 4 && index_tab5 == 1) {
                    $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
                }

                if (data && data.status == "0" && data.results.length > 0) {
                    // 格式化数据
                    for (var i = 0; i < data.results.length; i++) {
                        if (data.results[i].getImage && data.results[i].getImage.smallImageFrontUrl && (
                            data.results[i].getImage.smallImageFrontUrl == null || data.results[i].getImage.smallImageFrontUrl == "")) {
                            data.results[i].getImage.smallImageFrontUrl = NoPicture();
                        };
                        // 评分

                        data.results[i].colligationScore = formatScore(data.results[i].colligationScore);

                        // 距离
                        data.results[i].distance = ISS.utils.toFixed(data.results[i].distance, 2);
                        if (data.results[i].mobileOutUrl && data.results[i].mobileOutUrl != null &&
                            data.results[i].mobileOutUrl != "") {
                            data.results[i].mobileOutUrl = encodeURIComponent(data.results[i].mobileOutUrl);
                        };
                    };
                    var searchTemplate = $$('#template-scenic-tab2').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        if (current_tabindex == 0) $$("#scenic_tab2 #sub_tab1 .content-block ul").append(html);
                        else if (current_tabindex == 1) $$("#scenic_tab2 #sub_tab2 .content-block ul").append(html);
                        else if (current_tabindex == 2) $$("#scenic_tab2 #sub_tab3 .content-block ul").append(html);
                        else if (current_tabindex == 3) $$("#scenic_tab2 #sub_tab4 .content-block ul").append(html);
                        else if (current_tabindex == 4) $$("#scenic_tab2 #sub_tab5 .content-block ul").append(html);
                        flag_InfiniteScroll = flag_needScroll = true;
                    }


                    //tab1综合,无限滚动只加载一次
                    if (!flag_execute) {
                        //只执行一次
                        flag_execute = true;


                        $$('.infinite-scroll').on('infinite', function () {
                            //综合 价格 距离 切换
                            if (!flag_needScroll) {
                                flag_needScroll = true;
                                return;
                            }

                            //查询时,删除滚动后重新绑定pageindex
                            if (!flag_InfiniteScroll) {
                                flag_InfiniteScroll = true;
                                return;
                            }

                            if ($$("#a_food_tab2").hasClass("active")) {
                                // 如果正在加载，则退出
                                if (loading) return;
                                // 设置flag
                                loading = true;
                                // 模拟1s的加载过程
                                setTimeout(function () {

                                    if (current_tabindex == 0) {
                                        index_tab1++;
                                        LoadTicketAll(index_tab1, pagesize);
                                    }
                                    else if (current_tabindex == 1) {
                                        index_tab2++;
                                        LoadTicketAll(index_tab2, pagesize);
                                    }
                                    else if (current_tabindex == 2) {
                                        index_tab3++;
                                        LoadTicketAll(index_tab3, pagesize);
                                    }
                                    else if (current_tabindex == 3) {
                                        index_tab4++;
                                        LoadTicketAll(index_tab4, pagesize);
                                    }
                                    else if (current_tabindex == 4) {
                                        index_tab5++;
                                        LoadTicketAll(index_tab5, pagesize);
                                    }

                                }, 100);
                            }
                        });
                    }
                    if (current_tabindex == 0 && $$("#scenic_tab2 #sub_tab1 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader1').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 1 && $$("#scenic_tab2 #sub_tab2 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader2').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 2 && $$("#scenic_tab2 #sub_tab3 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader3').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 3 && $$("#scenic_tab2 #sub_tab4 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader4').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 4 && $$("#scenic_tab2 #sub_tab5 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader5').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                }
                else {
                    // 删除加载提示符
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    if (current_tabindex == 0) {
                        $$('.infinite-scroll-preloader1').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab1 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab1 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab1 .noAnswer").on("click", function () {
                                index_tab1 = 1;

                                LoadTicketAll(index_tab1, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 1) {
                        $$('.infinite-scroll-preloader2').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab2 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab2 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab2 .noAnswer").on("click", function () {
                                index_tab2 = 1;

                                LoadTicketAll(index_tab2, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 2) {
                        $$('.infinite-scroll-preloader3').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab3 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab3 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab3 .noAnswer").on("click", function () {
                                index_tab3 = 1;

                                LoadTicketAll(index_tab3, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 3) {
                        $$('.infinite-scroll-preloader4').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab4 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab4 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab4 .noAnswer").on("click", function () {
                                index_tab4 = 1;

                                LoadTicketAll(index_tab4, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 4) {
                        $$('.infinite-scroll-preloader5').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab5 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab5 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab5 .noAnswer").on("click", function () {
                                index_tab5 = 1;

                                LoadTicketAll(index_tab5, current_tabindex);
                            });
                        }
                    }
                }
            },
            error: function (xhr, status) {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
                loading = false;
            }
        });
    }

    // 搜索
    var mySearchbar = myApp.searchbar('.searchbar', {
        customSearch: true,
        onClear: function (s) { // clear

        }
    });

    //搜索框 Enter
    $$(".searchbar-input input").keydown(function (key) {
        if (key.keyCode == 13) {
            myApp.attachInfiniteScroll($$('.infinite-scroll'));
            $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
            $$(".noAnswer").remove();


            flag_InfiniteScroll = false;
            flag_needScroll = true;
            index_tab1 = index_tab2 = index_tab3 = index_tab4 = index_tab5 = 1;
            if (current_tabindex == 0) LoadTicketAll(index_tab1, size);
            else if (current_tabindex == 1) LoadTicketAll(index_tab2, size);
            else if (current_tabindex == 2) LoadTicketAll(index_tab3, size);
            else if (current_tabindex == 3) LoadTicketAll(index_tab4, size);
            else if (current_tabindex == 4) LoadTicketAll(index_tab5, size);

        }
    });

    //查询条件
    $$(".view-right .right a.close-panel").on("click", function () {
        myApp.attachInfiniteScroll($$('.infinite-scroll'));
        $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
        $$(".noAnswer").remove();


        flag_InfiniteScroll = false;
        flag_needScroll = true;
        index_tab1 = index_tab2 = index_tab3 = index_tab4 = index_tab5 = 1;
        if (current_tabindex == 0) LoadTicketAll(index_tab1, size);
        else if (current_tabindex == 1) LoadTicketAll(index_tab2, size);
        else if (current_tabindex == 2) LoadTicketAll(index_tab3, size);
        else if (current_tabindex == 3) LoadTicketAll(index_tab4, size);
        else if (current_tabindex == 4) LoadTicketAll(index_tab5, size);
    });

    //综合 价格 距离切换
    $$("#sub_buttons_row a").click(function () {
        $$('.infinite-scroll').scrollTop(0);
        current_tabindex = $$(this).index();
        myApp.attachInfiniteScroll($$('.infinite-scroll'));
        $$(".noAnswer").remove();

        flag_InfiniteScroll = true;
        flag_needScroll = false;
        if ($$(this).index() == 0 && $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab1, size);
        }
        else if ($$(this).index() == 1 && $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab2, size);
        }
        else if ($$(this).index() == 2 && $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab3, size);
        }
        else if ($$(this).index() == 3 && $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab4, size);
        }
        else if ($$(this).index() == 4 && $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab5, size);
        }
    });
});

/* 景区 */
var contactsCallback_ticket = myApp.onPageInit('ticket', function (page) {
    var type = ISS.utils.getParameter("type");
    if (type != null && type != undefined && type != "") {
        $$("#ticket_page .navbar .left a").attr("data-action", "history");
        $$("#ticket_page .navbar .left a i").removeClass("iconfont");
        $$("#ticket_page .navbar .left a i").removeClass("icon-shouye");
        $$("#ticket_page .navbar .left a i").addClass("icon");
        $$("#ticket_page .navbar .left a i").addClass("icon-back");
    }

    // 过滤 全部美食显示
    $$(".navbar-inner .right img").show();

    /* 筛选条件 */
    $$(".navbar-inner .right img").hide();


    var pickerRegion; //所在区域
    var pickerScenicType; //景区类型
    var pickerScenicStar; //景区等级
    var pickerScenicPriceRange; //价格范围

    pickerRegion = myApp.picker({
        input: '#sel_region_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.district(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.district(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicType = myApp.picker({
        input: '#sel_scenic_type_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicType(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicType(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicStar = myApp.picker({
        input: '#sel_scenic_star_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicStar(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicStar(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    pickerScenicPriceRange = myApp.picker({
        input: '#sel_scenic_price_range_value',
        toolbarTemplate:
        '<div class="toolbar theme-red">' +
        '<div class="toolbar-inner">' +
        '<div class="left"></div>' +
        '<div class="right">' +
        '<a href="#" class="link close-picker">确定</a>' +
        '</div>' +
        '</div>' +
        '</div>',
        formatValue: function (p, values, displayValues) {
            return displayValues;
        },
        cols: [
            {
                textAlign: 'center',
                values: (function () {
                    var arrValue = [];
                    $$.each(iss_dictionaryBaseData.scenicPriceRange(), function (i, obj) {
                        arrValue.push(obj.value);
                    });
                    return arrValue;
                })(),
                displayValues: (function () {
                    var arrDisplay = [];
                    $$.each(iss_dictionaryBaseData.scenicPriceRange(), function (i, obj) {
                        arrDisplay.push(obj.display);
                    });
                    return arrDisplay;
                })()
            }
        ]
    });

    // 过滤
    //$$(".navbar-inner .right img").hide();
    //$$('.voice img').show();
    //删除滚动后重新添加滚动
    var flag_InfiniteScroll = true;
    //是否需要滚动加载
    var flag_needScroll = true;
    //滚动事件只执行一次
    var flag_execute = false;

    var index_tab1 = 1;
    var index_tab2 = 1;
    var index_tab3 = 1;
    var index_tab4 = 1;
    var index_tab5 = 1;
    var current_tabindex = 0;
    var size = 10;
    // 加载flag
    var loading = false;
    /* 分类 */

    current_tabindex = 1;
    $$("#sub_buttons_row a").eq(0).removeClass("active");
    $$("#sub_buttons_row a").eq(0).hide();
    $$("#sub_buttons_row a").eq(1).addClass("active");
    $$("#scenic_tab2 #sub_tab1").removeClass("active");
    $$("#scenic_tab2 #sub_tab2").addClass("active");
    // 默认加载全部
    LoadTicketAll(index_tab2, size);


    //加载数据
    function LoadTicketAll(pageindex, pagesize) {
        var v_search = [];
        var v_order = [];

        var v_longitude = "";
        var v_latitude = "";

        // 站点
        if (_cityCode != "") {
            var opt = {
                SearchField: "CityCode",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: _cityCode
                    }
                ]
            };
            v_search.push(opt);
        }

        //区域
        if (pickerRegion && pickerRegion.value && pickerRegion.value.length > 0) {
            v_search.push(
                {
                    SearchField: "District",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerRegion.value[0]
                        }
                    ]
                }
            );
        }

        if (pickerScenicType && pickerScenicType.value && pickerScenicType.value.length > 0) {
            v_search.push(
                {
                    SearchField: "AttrType",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicType.value[0]
                        }
                    ]
                }
            );
        }

        if (pickerScenicStar && pickerScenicStar.value && pickerScenicStar.value.length > 0) {
            v_search.push(
                {
                    SearchField: "AttrRating",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicStar.value[0]
                        }
                    ]
                }
            );
        }

        if (pickerScenicPriceRange && pickerScenicPriceRange.value) {
            v_search.push(
                {
                    SearchField: "PriceRange",
                    ConditionType: 1,
                    AndOR: "and",
                    ListSearchValue: [
                        {
                            ItemValue: pickerScenicPriceRange.value[0]
                        }
                    ]
                }
            );
        }

        // 搜索条件
        if (mySearchbar && mySearchbar.query) {
            var opt = {
                SearchName: "名称",
                SearchField: "Keyword",
                ConditionType: 1,
                AndOR: "and",
                ListSearchValue: [
                    {
                        ItemValue: mySearchbar.query
                    }
                ]
            };
            v_search.push(opt);
        }

        // 排序
        if (current_tabindex == 0) {
            v_order = [
                {
                    OrderName: "最新",
                    OrderField: "ModifyTime", //排序字段
                    OrderType: "desc"
                }
            ];
        }
        if (current_tabindex == 1) {
            v_order = [
                {
                    OrderField: "Sort", //排序字段
                    OrderType: "desc"
                }
            ];
        }
        else if (current_tabindex == 2) {
            v_order = [
                {
                    OrderField: "scoreOrder", //排序字段
                    OrderType: "asc"
                }
            ];
        }
        else if (current_tabindex == 3) {
            v_order = [
                {
                    OrderField: "priceOrder", //排序字段
                    OrderType: "asc"
                }
            ];
        }
        else if (current_tabindex == 4) {
            v_order = [
                {
                    OrderField: "distanceOrder", //排序字段
                    OrderType: "asc"
                }
            ];
        }

        if (_isOpenPosition) {
            v_longitude = iss_localStorage.get("yuqing_longitude");
            v_latitude = iss_localStorage.get("yuqing_latitude");
        }
        else {
            v_longitude = iss_dictionaryBaseData.longitude;
            v_latitude = iss_dictionaryBaseData.latitude;
        }

        var _content = JSON.stringify({
            type: 0,
            conditionParams: {
                Page: {
                    PageSize: pagesize,
                    PageIndex: pageindex
                },
                Search: v_search,
                Order: v_order
            },
            lng: v_longitude,
            lat: v_latitude,
        })

        myApp.showPreloader();
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR,
            data: { "content": _content },

            crossDomain: true,
            method: "POST",
            success: function (data, status) {
                myApp.hidePreloader();
                data = JSON.parse(data);
                loading = false;
                if (current_tabindex == 0 && index_tab1 == 1) {
                    $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 1 && index_tab2 == 1) {
                    $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 2 && index_tab3 == 1) {
                    $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 3 && index_tab4 == 1) {
                    $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
                }
                if (current_tabindex == 4 && index_tab5 == 1) {
                    $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
                }

                if (data && data.status == "0" && data.results.length > 0) {
                    // 格式化数据
                    for (var i = 0; i < data.results.length; i++) {
                        data.results[i] = getDefaultImg(data.results[i]);
                        // 评分

                        data.results[i].colligationScore = formatScore(data.results[i].colligationScore);

                        // 距离
                        data.results[i].distance = ISS.utils.toFixed(data.results[i].distance, 2);
                        if (data.results[i].mobileOutUrl && data.results[i].mobileOutUrl != null &&
                            data.results[i].mobileOutUrl != "") {
                            data.results[i].mobileOutUrl = encodeURIComponent(data.results[i].mobileOutUrl);
                        };
                    };
                    var searchTemplate = $$('#template-scenic-tab2').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);
                        var html = compiledTemplate(data);
                        if (current_tabindex == 0) $$("#scenic_tab2 #sub_tab1 .content-block ul").append(html);
                        else if (current_tabindex == 1) $$("#scenic_tab2 #sub_tab2 .content-block ul").append(html);
                        else if (current_tabindex == 2) $$("#scenic_tab2 #sub_tab3 .content-block ul").append(html);
                        else if (current_tabindex == 3) $$("#scenic_tab2 #sub_tab4 .content-block ul").append(html);
                        else if (current_tabindex == 4) $$("#scenic_tab2 #sub_tab5 .content-block ul").append(html);
                        flag_InfiniteScroll = flag_needScroll = true;
                    }

                    //tab1综合,无限滚动只加载一次
                    if (!flag_execute) {
                        //只执行一次
                        //flag_execute = true;


                        $$('.infinite-scroll').on('infinite', function () {
                            //综合 价格 距离 切换
                            if (!flag_needScroll) {
                                flag_needScroll = true;
                                return;
                            }

                            //查询时,删除滚动后重新绑定pageindex
                            if (!flag_InfiniteScroll) {
                                flag_InfiniteScroll = true;
                                return;
                            }

                            if (true) {
                                // 如果正在加载，则退出
                                if (loading) return;
                                // 设置flag
                                loading = true;
                                // 模拟1s的加载过程
                                setTimeout(function () {

                                    if (current_tabindex == 0) {
                                        index_tab1++;
                                        LoadTicketAll(index_tab1, pagesize);
                                    }
                                    else if (current_tabindex == 1) {
                                        index_tab2++;
                                        LoadTicketAll(index_tab2, pagesize);
                                    }
                                    else if (current_tabindex == 2) {
                                        index_tab3++;
                                        LoadTicketAll(index_tab3, pagesize);
                                    }
                                    else if (current_tabindex == 3) {
                                        index_tab4++;
                                        LoadTicketAll(index_tab4, pagesize);
                                    }
                                    else if (current_tabindex == 4) {
                                        index_tab5++;
                                        LoadTicketAll(index_tab5, pagesize);
                                    }

                                }, 100);
                            }
                        });
                    }
                    if (current_tabindex == 0 && $$("#scenic_tab2 #sub_tab1 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader1').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 1 && $$("#scenic_tab2 #sub_tab2 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader2').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 2 && $$("#scenic_tab2 #sub_tab3 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader3').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 3 && $$("#scenic_tab2 #sub_tab4 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader4').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                    else if (current_tabindex == 4 && $$("#scenic_tab2 #sub_tab5 .content-block ul li").length >= data.total) {
                        // 删除加载提示符
                        $$('.infinite-scroll-preloader5').remove();
                        // 加载完毕，则注销无限加载事件，以防不必要的加载
                        myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    }
                }
                else {
                    // 删除加载提示符
                    myApp.detachInfiniteScroll($$('.infinite-scroll'));
                    if (current_tabindex == 0) {
                        $$('.infinite-scroll-preloader1').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab1 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab1 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab1 .noAnswer").on("click", function () {
                                index_tab1 = 1;

                                LoadTicketAll(index_tab1, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 1) {
                        $$('.infinite-scroll-preloader2').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab2 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab2 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab2 .noAnswer").on("click", function () {
                                index_tab2 = 1;

                                LoadTicketAll(index_tab2, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 2) {
                        $$('.infinite-scroll-preloader3').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab3 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab3 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab3 .noAnswer").on("click", function () {
                                index_tab3 = 1;

                                LoadTicketAll(index_tab3, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 3) {
                        $$('.infinite-scroll-preloader4').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab4 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab4 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab4 .noAnswer").on("click", function () {
                                index_tab4 = 1;

                                LoadTicketAll(index_tab4, current_tabindex);
                            });
                        }
                    }
                    else if (current_tabindex == 4) {
                        $$('.infinite-scroll-preloader5').remove();
                        // 删除多余的提示
                        $$("#scenic_tab2 #sub_tab5 .content-block .noAnswer").remove();
                        if (pageindex == 1) {
                            $$("#scenic_tab2 #sub_tab5 .content-block").html(ISS_Element.DIV.noAnswer);
                            $$("#scenic_tab2 #sub_tab5 .noAnswer").on("click", function () {
                                index_tab5 = 1;

                                LoadTicketAll(index_tab5, current_tabindex);
                            });
                        }
                    }
                }
            },
            error: function (xhr, status) {
                myApp.hidePreloader();
                myApp.alert("服务器连接失败！");
                loading = false;
            }
        });
    }

    // 搜索
    var mySearchbar = myApp.searchbar('.searchbar', {
        customSearch: true,
        onClear: function (s) { // clear

        }
    });

    //搜索框 Enter
    $$(".searchbar-input input").keydown(function (key) {
        if (key.keyCode == 13) {
            myApp.attachInfiniteScroll($$('.infinite-scroll'));
            $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
            $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
            $$(".noAnswer").remove();


            flag_InfiniteScroll = false;
            flag_needScroll = true;
            index_tab1 = index_tab2 = index_tab3 = index_tab4 = index_tab5 = 1;
            if (current_tabindex == 0) LoadTicketAll(index_tab1, size);
            else if (current_tabindex == 1) LoadTicketAll(index_tab2, size);
            else if (current_tabindex == 2) LoadTicketAll(index_tab3, size);
            else if (current_tabindex == 3) LoadTicketAll(index_tab4, size);
            else if (current_tabindex == 4) LoadTicketAll(index_tab5, size);

        }
    });

    //查询条件
    $$(".view-right .right a.close-panel").on("click", function () {
        myApp.attachInfiniteScroll($$('.infinite-scroll'));
        $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").remove();
        $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").remove();
        $$(".noAnswer").remove();


        flag_InfiniteScroll = false;
        flag_needScroll = true;
        index_tab1 = index_tab2 = index_tab3 = index_tab4 = index_tab5 = 1;
        if (current_tabindex == 0) LoadTicketAll(index_tab1, size);
        else if (current_tabindex == 1) LoadTicketAll(index_tab2, size);
        else if (current_tabindex == 2) LoadTicketAll(index_tab3, size);
        else if (current_tabindex == 3) LoadTicketAll(index_tab4, size);
        else if (current_tabindex == 4) LoadTicketAll(index_tab5, size);
    });

    //综合 价格 距离切换
    $$("#sub_buttons_row").on("click", "a", function () {
        $$('.infinite-scroll').scrollTop(0);
        current_tabindex = $$(this).index();
        myApp.attachInfiniteScroll($$('.infinite-scroll'));
        $$(".noAnswer").remove();

        flag_InfiniteScroll = true;
        flag_needScroll = false;
        if ($$(this).index() == 0 && $$("#scenic_tab2 #sub_tab1 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab1, size);
        }
        else if ($$(this).index() == 1 && $$("#scenic_tab2 #sub_tab2 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab2, size);
        }
        else if ($$(this).index() == 2 && $$("#scenic_tab2 #sub_tab3 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab3, size);
        }
        else if ($$(this).index() == 3 && $$("#scenic_tab2 #sub_tab4 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab4, size);
        }
        else if ($$(this).index() == 4 && $$("#scenic_tab2 #sub_tab5 .content-block ul").children("li").length == 0) {
            LoadTicketAll(index_tab5, size);
        }
    });
});

/* 景区详情  */
var contactsCallback_ticketDetail = myApp.onPageInit('ticketDetail', function (page) {
    var ImageList = [];

    //获取页面参数
    var ticketdetail_guid = ISS.utils.getParameter("ticketdetail_guid");
    if (ISS.utils.getParameter("action") != null && ISS.utils.getParameter("action") != undefined && ISS.utils.getParameter("action") == "history") {
        $$("#ticket_detail_page .navbar-inner .left a").attr("data-action", "history");
    } else {
        $$("#ticket_detail_page .navbar-inner .left a").attr("data-action", "back");
    }
    if (page != undefined) {
        ticketdetail_guid = page.query.ticketdetail_guid;

    }

    var _content = JSON.stringify({
        type: "1",
        Code: ticketdetail_guid
    })
    getDetail();
    function getDetail() {
        $$.ajax({
            url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR,
            data: { "content": _content },
            crossDomain: true,
            method: "POST",
            success: function (sdata, status) {
                var data = JSON.parse(sdata);
                if (data && data.status == "0" && data.results) {
                    scenicName = data.results.cnName;

                    data.results.shortsummary = "";
                    if (data.results.summary.length > 130) {
                        data.results.shortsummary = data.results.summary.substring(0, 130) + "...";
                    }
                    data = data.results;
                    var searchTemplate = $$('#template_scenic_scenery_detail').html();
                    if (searchTemplate) {
                        var compiledTemplate = Template7.compile(searchTemplate);

                        //处理主图片
                        data = getDefaultImg(data);

                        data.telephone = $.trim(data.telephone) == "" ? "暂无电话" : data.telephone;
                        //处理子景区、子景点图片
                        if (data.getScenery != undefined && data.getScenery != null || data.getScenery.length > 0) {
                            for (var i = 0; i < data.getScenery.length; i++) {
                                if (data.getScenery[i].getImage == undefined || data.getScenery[i].getImage == null || data.getScenery[i].getImage == "") {
                                    //data.getScenery[i].getImage.smallImageFrontUrl = NoPicture();
                                }
                                else {
                                    data.getScenery[i].getImage.smallImageFrontUrl = encodeURI(data.getScenery[i].getImage.smallImageFrontUrl);
                                }
                            }
                        } else if (data.getAttractions != undefined && data.getAttractions != null || data.getAttractions.length > 0) {
                            for (var i = 0; i < data.getAttractions.length; i++) {
                                if (data.getAttractions[i].getImage == undefined || data.getAttractions[i].getImage == null || data.getAttractions[i].getImage == "") {
                                    //data.getAttractions[i].smallImageFrontUrl = NoPicture();
                                }
                                else {
                                    data.getAttractions[i].getImage.smallImageFrontUrl = encodeURI(data.getAttractions[i].getImage.smallImageFrontUrl);
                                }
                            }
                        }
                        var html = compiledTemplate(data);
                        $$("#ticket_detail_page .page-content-scenic-detail").html(html);

                        //头部图片滑动
                        if (data.getImage.imageList.length > 0) {
                            var slidesperview = 3;
                            if (data.getImage.imageList.length == 1) {
                                slidesperview = 1;
                            } else if (data.getImage.imageList.length == 2) {
                                slidesperview = 2;
                            }

                            var mySwiper = new Swiper('.swiper-ticketDetail', {
                                pagination: '.swiper-ticketDetail .swiper-pagination',
                                autoplay: 5000,
                                speed: 300,
                                spaceBetween: 5,
                                slidesPerView: slidesperview
                            });

                            var ImageList = [];
                            var middleImageList = [];
                            for (var i = 0; i < data.getImage.imageList.length; i++) {
                                ImageList[i] = data.getImage.imageList[i].smallImgSrc;
                                middleImageList[i] = data.getImage.imageList[i].middleImgSrc;
                            }
                            $$("#ticket_detail_page #swiper").attr("yuqing_ImgList", JSON.stringify(ImageList));
                            $$("#ticket_detail_page #swiper").attr("yuqing_middleImageList", JSON.stringify(middleImageList));

                            $$("#ticket_detail_page #swiper").on("click", function () {
                                event.stopPropagation();
                                iss_localStorage.set("yuqing_ImgList", JSON.parse($$(this).attr("yuqing_ImgList")));
                                iss_localStorage.set("yuqing_middleImageList", JSON.parse($$(this).attr("yuqing_middleImageList")));
                                mainView.router.load({ url: "../../view/common/showImageList.html" });
                            })
                        }
                    }
                }
            },
            error: function (xhr, status) {
                console.log("ajax error!");
            }
        });
    }


    $$("#ticket_detail_page .page-content").on("click", "a.more", function () {
        var action = $$(this).find("i")[0];
        if ($$(action).hasClass("icon-gengduo")) {
            //显示更多
            $$(this).prev("p.all").show().prev("p.short").hide();
            $$(action).removeClass("icon-gengduo").addClass("icon-shouqi");
            var html = $$(action).parent().html();
            html = html.replace("查看", "收起");
            $$(action).parent().html(html);
        }
        else {
            $$(this).prev("p.all").hide().prev("p.short").show();
            $$(action).removeClass("icon-shouqi").addClass("icon-gengduo");
            var html = $$(action).parent().html();
            html = html.replace("收起", "查看");
            $$(action).parent().html(html);
        }
    })

    $$("#ticket_detail_page .page-content").on("click", "div.swiper-container", function () {
        mainView.router.loadPage({ url: $$(this).attr("data-href"), reload: false });
        // window.location.href=$$(this).attr("data-href");
    })
});

/* 景点详情  */
var contactsCallback_ticketDetail02 = myApp.onPageInit('ticketDetail02', function (page) {
    //获取页面参数
    var ticketdetail02_guid = ISS.utils.getParameter("ticketdetail02_guid");
    var tCode = ISS.utils.getParameter("tCode");
    if (page != undefined) {
        ticketdetail02_guid = page.query.ticketdetail02_guid;
        tCode = page.query.tCode;
    }
    var _content = JSON.stringify({
        type: "2",
        Code: ticketdetail02_guid
    })
    $$.ajax({
        url: ISS_Constants.Url.defaulturl + ISS_Constants.serviceName.ATTAR,
        data: { "content": _content },

        crossDomain: true,
        method: "POST",
        success: function (data, status) {
            data = JSON.parse(data);
            if (data && data.status == "0" && data.results) {
                data = data.results;
                var searchTemplate = $$('#ticket_detail02_page #template_scenic_point_detail').html();
                if (searchTemplate) {
                    var compiledTemplate = Template7.compile(searchTemplate);
                    //处理主图片
                    if (data.getImage == null || data.getImage == undefined || data.getImage.imageList.length == 0) data.getImage = { imageList: [{ middleImgSrc: NoPicture() }] }
                    if (data.getAtrImage == null || data.getAtrImage == undefined) data.getAtrImage = { smallImageFrontUrl: NoPicture() }
                    //处理其他景点
                    if (data.getOtherScenerys.length && data.getOtherScenerys.length > 3) {
                        var getOtherScenerys = [];
                        for (var i = 0; i < 3; i++) {
                            getOtherScenerys.push(data.getOtherScenerys[i]);
                        }
                        data.getOtherScenerys = getOtherScenerys;
                    }
                    for (var j = 0; j < data.getOtherScenerys.length; j++) {
                        if (data.getOtherScenerys[j].getImage == null || data.getOtherScenerys[j].getImage == undefined) {
                            data.getOtherScenerys[j].getImage = { smallImageFrontUrl: NoPicture() }
                        }
                    }

                    var html = compiledTemplate(data);
                    $$("#ticket_detail02_page .page-content-point-detail").html(html);
                }

                //头部图片滑动
                if (data.getImage.imageList.length > 0) {
                    var slidesperview = 3;
                    if (data.getImage.imageList.length == 1) {
                        slidesperview = 1;
                    } else if (data.getImage.imageList.length == 2) {
                        slidesperview = 2;
                    }

                    var mySwiper = new Swiper('.swiper-ticketDetail02', {
                        pagination: '.swiper-ticketDetail02 .swiper-pagination',
                        autoplay: 5000,
                        speed: 300,
                        spaceBetween: 5,
                        slidesPerView: slidesperview
                    });

                    var ImageList = [];
                    var middleImageList = [];
                    for (var i = 0; i < data.getImage.imageList.length; i++) {
                        ImageList[i] = data.getImage.imageList[i].smallImgSrc;
                        middleImageList[i] = data.getImage.imageList[i].middleImgSrc;
                    }
                    $$("#ticket_detail02_page #swiper").attr("yuqing_ImgList", JSON.stringify(ImageList));
                    $$("#ticket_detail02_page #swiper").attr("yuqing_middleImageList", JSON.stringify(middleImageList));

                    $$("#ticket_detail02_page #swiper").on("click", function () {
                        event.stopPropagation();
                        iss_localStorage.set("yuqing_ImgList", JSON.parse($$(this).attr("yuqing_ImgList")));
                        iss_localStorage.set("yuqing_middleImageList", JSON.parse($$(this).attr("yuqing_middleImageList")));
                        mainView.router.load({ url: "../../view/common/showImageList.html" });
                    })
                }
            }
        },
        error: function (xhr, status) {
            console.log("ajax error!");
        }
    });
    $$("#ticket_detail02_page .page-content").on("click", "div.swiper-container", function () {
        mainView.router.loadPage({ url: $$(this).attr("data-href"), reload: false });
        // window.location.href=$$(this).attr("data-href");
    })
});

/* 初始化  */
function initData() {
    var href = window.location.href;
    if (href.indexOf(scenic) > -1) {
        contactsCallback_scenic.trigger();
    }
    else if (href.indexOf(ticket) > -1) {
        contactsCallback_ticket.trigger();
    }
    else if (href.indexOf(ticketDetail) > -1) {
        contactsCallback_ticketDetail.trigger();
    }
    else if (href.indexOf(ticketDetail02) > -1) {
        contactsCallback_ticketDetail02.trigger();
    }
}

initData();

